package com.song.hbasechap_7_6;

import java.io.IOException;
import java.util.Map;

import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

public class ImportDataMapper extends Mapper<LongWritable ,Text , ImmutableBytesWritable , Put> {

//	private  String family="data";
//	private String  col= "mid";
	@Override
	protected void map(
			LongWritable key,
			Text value,
			Mapper<LongWritable, Text, ImmutableBytesWritable, Put>.Context context)
			throws IOException, InterruptedException {
		// TODO Auto-generated method stub
		
		String linestr = value.toString();
		
		Map<String,Put> map  = MapperManger.StringToPut(linestr);
		String rowkey = map.keySet().iterator().next();
		Put put = map.values().iterator().next();
		context.write(new ImmutableBytesWritable(Bytes.toBytes(rowkey ))  , put);
		
	}

}